<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/shop/client/css/login.css">
    <%@ include file="style.jsp" %>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.verify({
                username: function(value, item){ //value：表单的值、item：表单的DOM对象
                    if(value.length<=4){
                        return '用户名长度不能小于4位'
                    }
                    if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                        return '用户名不能有特殊字符';
                    }
                    if(/(^\_)|(\__)|(\_+$)/.test(value)){
                        return '用户名首尾不能出现下划线\'_\'';
                    }
                    if(/^\d+\d+\d$/.test(value)){
                        return '用户名不能全为数字';
                    }
                },
                password: function(value, item){ //value：表单的值、item：表单的DOM对象
                    if(value.length<=4){
                        return '密码长度不能小于4位'
                    }
                    if(!new RegExp("^[a-zA-Z0-9_\s·]+$").test(value)){
                        return '密码中不能有特殊字符';
                    }
                    if(/^\d+\d+\d$/.test(value)){
                        return '密码不能全为数字';
                    }

                }
            });
        });
    </script>
</head>

<body>


<%@ include file="start.jsp" %>
<!--  导航 end -->
<%@ include file="header.jsp" %>
<!--  header end -->
<!-- 中间头部 -->
<div class="layui-container login_box" style="width: 840px;margin-top: 25px;">
    <div class="layui-row">
        <div class="layui-panel box">
            <div class="layui-col-md5 desc">
                <h1>省心 极致 低价</h1>
                <p>一流品质，超级好货，便宜实惠</p>
            </div>
            <div class="layui-col-md7 content">
                <div class="login-title">
                    <h4>登录</h4>
                </div>
                <div class="login-panel ">
                    <form class="layui-form" action="login" method="get">
                        <div class="layui-form-item">
                            <label class="layui-form-label">账号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" required lay-verify="username"
                                       placeholder="请输入账号" autocomplete="off" class="layui-input" value="${cookie.username.value}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password" required
                                       placeholder="请输入密码" autocomplete="off" class="layui-input" value="${cookie.password.value}">
                            </div>
                        </div>
                        <div class="layui-form-item" style="display: flex">
                            <div>
                                <label class="layui-form-label">记住密码</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="remember" lay-skin="switch" checked>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    /**
     * 获取Cookie中的值
     * @param objName
     * @returns
     */
    function getCookie(objName){//获取指定名称的cookie的值
        var arrStr = document.cookie.split("; ");
        for (var i = 0; i < arrStr.length; i++) {
            var temp = arrStr[i].split("=");
            if (temp[0] == objName){
                return decodeURI(temp[1]);
            }
        }
    }
</script>
<%@include file="footer.jsp"%>
</body>

</html>